﻿package  com.devilcat.ws{
	import com.devilcat.ws.Basicws;
	import com.worlize.websocket.*;
	import com.devilcat.dt.Gamedt;
	
	public class UpdateUserEventws extends Basicws{
		var mUid:int;
		public function UpdateUserEventws() {
			super("iw-protocol");
			mUid=Gamedt.Player.uid;
			// constructor code
		}
		override function handleWebSocketOpen(event:WebSocketEvent):void
		{
		}
		public function Update(_event:String,_value:Number){
			//trace(_event+ " " +_value);
			var pack:Object = new Object();
			pack.uid=mUid;
			pack.action="updateevent";
			pack.eventname=_event;
			pack.eventnumber=_value;
			var myJson:String = JSONString(pack);
			websocket.sendUTF(myJson);
			
		}
		override function handleWebSocketMessage(event:WebSocketEvent):void
		{
			if (event.message.type === WebSocketMessage.TYPE_UTF8)
			{	
				debug(event.message.utf8Data);
				trace("Got message: " + event.message.utf8Data);
			}
		}

	}
	
}
